You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR ensures that we are not showing native alerts whenever someone tries to do so with the beforeunload event. With this change, the browser will always navigate to the new website.
Summary by CodeRabbit
Bug Fixes
Suppressed beforeunload event alerts on Android to prevent unnecessary confirmation prompts when navigating away from pages, enabling seamless user navigation.
A patch release for @phantom/react-native-webview that adds beforeunload event handling on Android. The new implementation automatically confirms beforeunload events without displaying alerts to users.
515-519: Consider adding isActive() check for consistency with other JS dialog handlers.
The existing onJsAlert, onJsConfirm, and onJsPrompt methods (lines 489-513) check mWebView.isActive() and cancel the result when inactive. This new handler unconditionally confirms.
If the intent is to always allow beforeunload without any dialog (as stated in the changeset), the current implementation is correct. However, for an inactive webview, you might want to call result.cancel() instead of result.confirm() to be consistent with the security pattern established by the other handlers.
If this is intentional (always proceed regardless of active state), a brief comment explaining the rationale would help future maintainers understand the design decision.
`@Override`
public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) {
+ // Always confirm beforeunload to prevent blocking navigation with dialogs
result.confirm();
return true; // Consumed - don't show default dialog
}
Comment @coderabbitai help to get the list of available commands and usage tips.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR ensures that we are not showing native alerts whenever someone tries to do so with the
beforeunloadevent. With this change, the browser will always navigate to the new website.Summary by CodeRabbit